<?php
// 本类由系统自动生成，仅供测试用途
class IndexAction extends Action {	
	public function uploadimages(){
		if($this->_get('value')){//判断是否删除图片
			$delete = base64_decode($this->_get('value'));
			if(in_array($delete,$_SESSION['uploadimages'])){//检查提交的图片是否存在session
			  unset($_SESSION['uploadimages'][array_search($delete,$_SESSION['uploadimages'])]);//删除对应的图片
			}
			foreach($_SESSION['uploadimages'] as $key => $value){
				echo '<img src="/tp/img/'.$value.'" width="300" height="300" /><br />';	
				echo '<a href="/tp/index.php/Index/uploadimages/value/'.base64_encode($value).'" id="mylink">删除</a><br />';
				
			}
			//session('uploadimages',NULL);
		}else{
			//上传图片
			import("ORG.Net.UploadFile");
			$upload = new UploadFile();
			$upload->maxSize  = 10485760 ;
			$upload->allowExts  = array('jpg', 'gif', 'png', 'jpeg','bmg');
			$upload->savePath =  'img/'.date('Ymd').'/';
			if(!$upload->upload()) {
				$this->error($upload->getErrorMsg());
			}else{
				$info =  $upload->getUploadFileInfo();
			}
			$_SESSION['uploadimages'][] = date('Ymd').'/'.$info[0]['savename'];//将图片放进session，并以数组形式保存
			foreach($_SESSION['uploadimages'] as $key => $value){
				echo '<img src="/tp/img/'.$value.'" width="300" height="300" /><br />';	
				echo '<a href="/tp/index.php/Index/uploadimages/value/'.base64_encode($value).'" id="mylink">删除</a><br />';
			}
		}
	}
}